﻿<navigation:PageView x:Class="Corina.Cydee.Apphub.Views.Users.UserHypotaxisView"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:controls="clr-namespace:Corina.Controls.Silverlight;assembly=Corina.Controls.Silverlight"
                     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                     xmlns:localViewmodel="clr-namespace:Corina.Cydee.Apphub.Viewmodels"
                     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                     xmlns:navigation="clr-namespace:Corina.Cydee.Apphub.Base"
                     xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                     d:DesignHeight="480"
                     d:DesignWidth="640"
                     mc:Ignorable="d">
    <navigation:PageView.DataContext>
        <localViewmodel:UserHypotaxisViewmodel />
    </navigation:PageView.DataContext>
    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="300" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <ListBox Background="Transparent"
                 ItemsSource="{Binding UserCollection}"
                 SelectedItem="{Binding SelectedUser,
                                        Mode=TwoWay}">
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ListBoxItem">
                                <Grid>
                                    <Grid Background="{StaticResource HighlightBrush}" Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <Grid Margin="3,6">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <TextBlock>
                                            <Run Text="{Binding Account}" />
                                            <Run Text="【" />
                                            <Run FontFamily="Portable User Interface" Text="{Binding Name}" />
                                            <Run Text="】" />
                                        </TextBlock>

                                        <controls:PathButton Grid.Column="1"
                                                             Command="{Binding Path=DataContext.ShowAllocateCommand,
                                                                               RelativeSource={RelativeSource AncestorType=navigation:PageView}}"
                                                             Foreground="White"
                                                             PathData="{StaticResource ICON_EDIT}"
                                                             Visibility="{Binding IsSelected,
                                                                                  Converter={StaticResource BooleanToVisibilityConverter},
                                                                                  RelativeSource={RelativeSource TemplatedParent}}" />
                                    </Grid>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>
        <Grid Grid.Column="1"
              Margin="24,0,0,0"
              Background="White">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.Effect>
                <DropShadowEffect BlurRadius="5"
                                  Direction="-90"
                                  ShadowDepth="1" />
            </Grid.Effect>
            <ListBox Background="Transparent"
                     ItemsSource="{Binding SubuserCollection}"
                     ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <toolkit:WrapPanel />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListBoxItem">
                                    <Grid Margin="0,0,12,12">
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualStateGroup.Transitions>
                                                    <VisualTransition GeneratedDuration="0:0:0.4">
                                                        <VisualTransition.GeneratedEasingFunction>
                                                            <BackEase EasingMode="EaseOut" />
                                                        </VisualTransition.GeneratedEasingFunction>
                                                    </VisualTransition>
                                                </VisualStateGroup.Transitions>
                                                <VisualState x:Name="Normal" />
                                                <VisualState x:Name="MouseOver">
                                                    <Storyboard>
                                                        <DoubleAnimation Duration="0"
                                                                         Storyboard.TargetName="button"
                                                                         Storyboard.TargetProperty="(Canvas.Left)"
                                                                         To="0"
                                                                         d:IsOptimized="True" />
                                                        <DoubleAnimation Duration="0"
                                                                         Storyboard.TargetName="border"
                                                                         Storyboard.TargetProperty="(UIElement.Opacity)"
                                                                         To="1"
                                                                         d:IsOptimized="True" />
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Disabled" />
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <Border x:Name="border"
                                                Background="{StaticResource HighlightBrush}"
                                                CornerRadius="2"
                                                Opacity="0" />
                                        <StackPanel Margin="3,6" Orientation="Horizontal">
                                            <TextBlock VerticalAlignment="Center">
                                                <Run Text="{Binding Account}" />
                                                <Run Text="【" />
                                                <Run Text="{Binding Name}" />
                                                <Run Text="】" />
                                            </TextBlock>
                                            <Canvas Width="16"
                                                    Height="16"
                                                    Margin="3,0">
                                                <Canvas.Clip>
                                                    <RectangleGeometry Rect="0,0,16,16" />
                                                </Canvas.Clip>
                                                <controls:PathButton x:Name="button"
                                                                     Canvas.Left="-16"
                                                                     Width="16"
                                                                     Height="16"
                                                                     Command="{Binding Path=DataContext.RemoveCommand,
                                                                                       RelativeSource={RelativeSource AncestorType=navigation:PageView}}"
                                                                     CommandParameter="{Binding Id}"
                                                                     Foreground="White"
                                                                     PathData="{StaticResource ICON_MINUS}" />
                                            </Canvas>
                                        </StackPanel>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>

            <Grid Grid.Row="1"
                  Height="300"
                  Visibility="{Binding ShowAllocate,
                                       Converter={StaticResource BooleanToVisibilityConverter}}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition />
                    <RowDefinition Height="auto" />
                </Grid.RowDefinitions>
                <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
                    <Path Width="24"
                          Height="24"
                          Margin="6,0"
                          Data="F1M753.644,-13.0589L753.736,-12.9639 753.557,-12.7816 732.137,8.63641 732.137,29.7119 756.445,5.40851 764.094,-2.24384 764.275,-2.42352 771.834,5.1286 796.137,29.4372 796.137,8.36163 774.722,-13.0589 764.181,-23.5967 753.644,-13.0589z"
                          Fill="{StaticResource HighlightBrush}"
                          RenderTransformOrigin="0.5,0.5"
                          Stretch="Uniform">
                        <Path.RenderTransform>
                            <TransformGroup>
                                <TransformGroup.Children>
                                    <RotateTransform Angle="0" />
                                    <ScaleTransform ScaleX="1" ScaleY="1" />
                                </TransformGroup.Children>
                            </TransformGroup>
                        </Path.RenderTransform>
                    </Path>
                    <Path Width="24"
                          Height="24"
                          Margin="6,0"
                          Data="F1M181.297,177.841L181.205,177.746 181.385,177.563 202.804,156.146 202.804,135.07 178.497,159.373 170.847,167.026 170.666,167.205 163.107,159.653 138.804,135.345 138.804,156.42 160.219,177.841 170.76,188.379 181.297,177.841z"
                          Fill="{StaticResource HighlightBrush}"
                          RenderTransformOrigin="0.5,0.5"
                          Stretch="Uniform">
                        <Path.RenderTransform>
                            <TransformGroup>
                                <TransformGroup.Children>
                                    <RotateTransform Angle="0" />
                                    <ScaleTransform ScaleX="1" ScaleY="1" />
                                </TransformGroup.Children>
                            </TransformGroup>
                        </Path.RenderTransform>
                    </Path>
                </StackPanel>

                <ListBox Grid.Row="1"
                         Background="Transparent"
                         ItemsSource="{Binding UnallocateCollection}"
                         ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <toolkit:WrapPanel />
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="ListBoxItem">
                                        <Grid Margin="0,0,12,12">
                                            <VisualStateManager.VisualStateGroups>
                                                <VisualStateGroup x:Name="CommonStates">
                                                    <VisualStateGroup.Transitions>
                                                        <VisualTransition GeneratedDuration="0:0:0.4">
                                                            <VisualTransition.GeneratedEasingFunction>
                                                                <BackEase EasingMode="EaseOut" />
                                                            </VisualTransition.GeneratedEasingFunction>
                                                        </VisualTransition>
                                                    </VisualStateGroup.Transitions>
                                                    <VisualState x:Name="Normal" />
                                                    <VisualState x:Name="MouseOver">
                                                        <Storyboard>
                                                            <DoubleAnimation Duration="0"
                                                                             Storyboard.TargetName="button"
                                                                             Storyboard.TargetProperty="(Canvas.Left)"
                                                                             To="0"
                                                                             d:IsOptimized="True" />
                                                            <DoubleAnimation Duration="0"
                                                                             Storyboard.TargetName="border"
                                                                             Storyboard.TargetProperty="(UIElement.Opacity)"
                                                                             To="1"
                                                                             d:IsOptimized="True" />
                                                        </Storyboard>
                                                    </VisualState>
                                                    <VisualState x:Name="Disabled" />
                                                </VisualStateGroup>
                                            </VisualStateManager.VisualStateGroups>
                                            <Border x:Name="border"
                                                    Background="{StaticResource HighlightBrush}"
                                                    CornerRadius="2"
                                                    Opacity="0" />
                                            <StackPanel Margin="3,6" Orientation="Horizontal">
                                                <TextBlock VerticalAlignment="Center">
                                                    <Run Text="{Binding Account}" />
                                                    <Run Text="【" />
                                                    <Run Text="{Binding Name}" />
                                                    <Run Text="】" />
                                                </TextBlock>
                                                <Canvas Width="16"
                                                        Height="16"
                                                        Margin="3,0">
                                                    <Canvas.Clip>
                                                        <RectangleGeometry Rect="0,0,16,16" />
                                                    </Canvas.Clip>
                                                    <controls:PathButton x:Name="button"
                                                                         Canvas.Left="-16"
                                                                         Width="16"
                                                                         Height="16"
                                                                         Command="{Binding Path=DataContext.AddCommand,
                                                                                           RelativeSource={RelativeSource AncestorType=navigation:PageView}}"
                                                                         CommandParameter="{Binding Id}"
                                                                         Foreground="White"
                                                                         PathData="{StaticResource ICON_ADD1}" />
                                                </Canvas>
                                            </StackPanel>
                                        </Grid>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ListBox.ItemContainerStyle>
                </ListBox>
                <Button Grid.Row="2"
                        MinWidth="60"
                        HorizontalAlignment="Right"
                        Command="{Binding SubmitCommand}"
                        Content="提交" />
            </Grid>
        </Grid>
    </Grid>
</navigation:PageView>
